package com.ylfstu.map_;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

@SuppressWarnings({"all"})
public class MapExercise {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("110",new Employee("ylf", 22000, "110"));
        map.put("111",new Employee("lily", 18000, "111"));
        map.put("112",new Employee("cathy", 15000, "112"));

        Set entrySet = map.entrySet();
        for (Object o : entrySet) {
            Map.Entry entry = (Map.Entry) o;
            System.out.println(entry.getKey() + "-" +entry.getValue());
        }

        System.out.println("-----遍历显示工资 > 18000 的员工-----");
        for (Object o : entrySet) {
            Map.Entry entry = (Map.Entry) o;
            Employee entry1 = (Employee) entry.getValue();
            if (entry1.getSal() > 18000)
                System.out.println(entry1);
        }

    }
}
class Employee{
    private String name;
    private double sal;
    private String id;

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", sal=" + sal +
                ", id='" + id + '\'' +
                '}';
    }

    public Employee(String name, double sal, String id) {
        this.name = name;
        this.sal = sal;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        this.sal = sal;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
